/**
 * 
 */
package fr.upvm.lem3.vm3d.ui.swing.frontend;


import java.util.List;
import java.util.Vector;

import javax.swing.JComponent;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JToolBar;

import fr.upvm.lem3.vm3d.domain.File3D;
import fr.upvm.lem3.vm3d.domain.imagebuilder.MedImage;
import fr.upvm.lem3.vm3d.ui.swing.menu.MyMenuBar;
import fr.upvm.lem3.vm3d.ui.swing.volume3d.TexturePanel;
import fr.upvm.lem3.vm3d.ui.swing.volume3d.TexturePanelController;
/**
 * @author Nougouapi
 *
 */
public class MainGUIController{
	
      
	private MainGUI mainFrame;
	
	public MainGUIController( MainGUI frame){
		this.mainFrame = frame;
	}
	
	private static String CLOSE_QUESTION = "Exit Application?";
	private static String DIALOG_TITLE = "Confirm Exit";
	/**
	 * close the main frame
	 */
	public void exitFrame(){
		//TODO uncomment this line at the end of the implementation of this application
		int n = JOptionPane.showConfirmDialog( getMainFrame(), CLOSE_QUESTION, DIALOG_TITLE, JOptionPane.YES_NO_OPTION);
	    if (n == JOptionPane.YES_OPTION) {
	    	getMainFrame().dispose();
			Runtime.getRuntime().exit(0);
	    } else { // dont exit the main frame otherwise
	    	getMainFrame().setDefaultCloseOperation(0);
	    }
//		getMainFrame().dispose();
//		Runtime.getRuntime().exit(0);
	}
	/**
	 * 
	 * @param c: the component
	 * @param flag (true or false, respectively for showing or hide the given component
	 */
	public void showHideToolbar( JComponent c, boolean flag){
		c.setVisible(flag);
	}
	/**
	 * @param mainGUI the mainGUI to set
	 */
	public void setMainFrame(MainGUI mainGUI) {
		mainFrame = mainGUI;
	}

	/**
	 * @return the mainGUI
	 */
	public MainGUI getMainFrame() {
		return mainFrame;
	}
	/**
	 * 
	 * @param myMenuBar
	 */
	public void adjustSplitpane(JMenuBar myMenuBar) {
				getMainFrame().adjustSplitpane((MyMenuBar)myMenuBar);
		
	}
	/**
	 * handle the file3d come from the data loader
	 * @param file3d
	 */
	public void handleFile3D(File3D file3d, boolean isNewFile3DLoaded) {
		getMainFrame().getInspectorPanel().getPanelTexture().setFile3d(file3d, isNewFile3DLoaded );
		
	}
	
	
	
	
}

